#include "base_maths.h"

int i_clamp(int val, int min, int max)
{
    if(val < min) val = min;
    if(val > max) val = max;
    return val;
}


//-----------------------------------------------------------------------------
// Vector
//-----------------------------------------------------------------------------


float vec2_dot(vec2 u, vec2 v)
{
    return u[0] * v[0] + u[1] * v[1];
}

float vec2_length(vec2 u)
{
    return sqrt(u[0]*u[0] + u[1]*u[1]);
}

void vec2_sub(vec2 dest, vec2 u, vec2 v)
{
    dest[0] = u[0] - v[0];
    dest[1] = u[1] - v[1];
    return;
}

void vec2_mult(vec2 dest, vec2 u, float k)
{
    dest[0] = u[0] * k;
    dest[1] = u[1] * k;
    return;
}
